set more off
clear all


local save_figures_flag=1

use ASEC_data.dta

rename asecwt weight
drop if empstat==1 /*drop armed forces, same as in Kendrick*/
drop if hflag==1 /*adjust for redesign in 2014, use a larger proportion (5/8) */
drop if schlcoll==1 
drop if schlcoll==3 /*exclude students*/

keep if age>=25 & age<=64
keep if year>=1964 /*data starts in 62 but is missing for 1963*/

gen skill=.
replace skill=1 if educ<80
replace skill=2 if educ>=110
drop if skill==.


gen h=.
replace h=ahrsworkt
replace h=. if ahrsworkt==999

gen w_ly=incwage
replace w_ly=. if incwage>=9999998

keep year skill w_ly h weight



sort year skill
by year skill: egen population=total(weight)
by year skill: egen hours=total(h*weight*52)
by year skill: egen wage_ly=total(w_ly*weight)
by year skill: gen id=_n
drop if id>1

keep year skill hours wage_ly population

sort skill year
by skill: gen wage=wage_ly[_n+1]
gen wage_per_hour=wage/hours
replace hours=hours/population

/*merge with CPI*/
merge m:1 year using "../BLS, price/CPI_all_long_USA"
drop _merge
drop if wage_per_hour==.
replace wage_per_hour=wage_per_hour/price_all
sort skill year

gen tag=.
replace tag=1 if year==1980
sort skill tag
by skill: gen wage_per_hour_norm=wage_per_hour/wage_per_hour[1]
by skill: gen hours_norm=hours/hours[1]
sort skill year 
drop tag

keep if year<=2017 /*to be comparable with other graphs*/

twoway (connected wage_per_hour_norm year if skill==1, lpattern(solid) msymbol(x) msize(large)  lwidth(0.4)) /*
*/ (connected wage_per_hour_norm year if skill==2, lpattern(dash) msymbol(o) msize(large)  lwidth(0.4)), xline(1980, lcolor(black)) /*
*/leg(label (1 "{&le} High School") label(2 "{&ge} College") position(11) ring(0) cols(1)) xlabel(1965[10]2017) ylabel(0.7[0.1]1.6) xtitle("")/*
*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax gmin) ytitle("Wage index, 1980=1") ylabel(,grid nogextend gmax gmin) ysize(4)
if `save_figures_flag'==1 {
	graph export "../../figures/skill_prem_leg.png", as(png) replace
	graph export "../../figures/skill_prem_leg.eps", as(eps) replace
}
*black and white
twoway (connected wage_per_hour_norm year if skill==1, lpattern(solid) msymbol(x) msize(large)  lwidth(0.4)) /*
*/ (connected wage_per_hour_norm year if skill==2, lpattern(dash) msymbol(o) msize(large)  lwidth(0.4)), xline(1980, lcolor(black)) /*
*/leg(label (1 "{&le} High School") label(2 "{&ge} College") position(11) ring(0) cols(1)) xlabel(1965[10]2017) ylabel(0.7[0.1]1.6) xtitle("")/*
*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax gmin) ytitle("Wage index, 1980=1") ylabel(,grid nogextend gmax gmin) ysize(4) scheme(s1mono)
if `save_figures_flag'==1 {
	graph export "../../figures/skill_prem_leg_bw.png", as(png) replace
	graph export "../../figures/skill_prem_leg_bw.eps", as(eps) replace
}
